home *** CD-ROM | disk | FTP | other *** search
- Path: atglab.bls.com!Alun.Champion
- From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
- Newsgroups: comp.lang.c++
- Subject: Re: Deep/Shallow Copying?
- Date: 10 Jan 1996 22:09:19 GMT
- Organization: Computer People Inc.
- Message-ID: <ALUN.CHAMPION.96Jan10170919@g7240065.bridge.bst.bls.com>
- References: <4d1bhe$1lto@bocanews.bocaraton.ibm.com>
- NNTP-Posting-Host: bstfirewall.bst.bls.com
- In-reply-to: pani@genius.tisl.soft.net's message of 10 Jan 1996 21:36:46 GMT
-
- In article <4d1bhe$1lto@bocanews.bocaraton.ibm.com> pani@genius.tisl.soft.net writes:
-
- : What is Deep copying or Shallow copying? Is this something
- : to do with a Copy constructor?
-
- Yes.
- A picture may illustrate the scenario
-
- Imagine object 'a' contains a pointer or reference to object 'b' then:
-
- Original Shallow Copy Deep Copy
-
- --------- --------- ---------
- | a | | new a | | new a |
- --------- --------- ---------
- | | |
- V V V
- --------- --------- ---------
- | b | | b | | new b |
- --------- --------- ---------
-
- Of course 'a' may contain many pointers and/or references which in turn
- may contain many pointers and/or references etc... Obviously the deeper
- the structure the more expensive deep copy is compared to shallow copy.
-
- Hope this helps
- Regards
-
- -A.
-
-
-
- --
- | A.Champion |
-